package com.wxy.demo.client;

import com.wxy.demo.server.MyService;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.URL;

/**
 * @author wangxiaoyuan
 * 2021/3/19 15:21
 **/
public class JdkClient {
    public static void main(String[] args) throws Exception {
        URL url = new URL("http://localhost:8089/myservice?wsdl");
        // 指定命名空间和服务名称
        QName qName = new QName("http://com.soft.ws/my", "MyService");
        Service service = Service.create(url, qName);
        // 通过getPort方法返回指定接口
        MyService myServer = service.getPort(new QName("http://com.soft.ws/my",
                "LoginPort"), MyService.class);
        // 调用方法 获取返回值
        String result = myServer.authorization("admin", "123456");
        System.out.println(result);
    }
}
